﻿@inject ISysAuthService SysAuthService
@inject IJSRuntime Js
@inject NavigationManager Navigation

<Navbar Theme="NavbarTheme.None" class="shadow-none">
    <NavbarMenu>
        <NavbarGroup>
            <NavbarItem class="ms-4">
                <BaseBreadcrumb/>
            </NavbarItem>
        </NavbarGroup>

        <NavbarGroup IsTail>

            <NavbarItem>
                <QuickSearch Items="@State.Leaves" SearchAccessor="@(x => x.Text)" OnSelectedItemChanged="@OnSelectedItemChanged" IsLikeMatch></QuickSearch>
            </NavbarItem>

            <div class="vr mx-4 "></div>

            <NavbarItem class="ms-2">
                <FullScreenButton class="nav-link" Title="点击切换全屏模式" />
            </NavbarItem>

            <NavbarItem class="me-4"> 
                <DropdownWidget>
                    <DropdownWidgetItem Icon="fa fa-bell-o" BadgeNumber="10" HeaderColor="Color.Success" BadgeColor="Color.Warning">
                        <HeaderTemplate>
                            <span>您有 10 个未读通知</span>
                        </HeaderTemplate>
                        <BodyTemplate>
                            @for (var index = 0; index < 10; index++)
                            {
                                <a class="dropdown-item d-flex align-items-center" href="#" @onclick:preventDefault>
                                    <i class="fa fa-users text-primary"></i>
                                    <div class="ms-2">5 new members joined</div>
                                </a>
                            }
                        </BodyTemplate>
                        <FooterTemplate>
                            <a href="#" @onclick:preventDefault>查看所有通知</a>
                        </FooterTemplate>
                    </DropdownWidgetItem>
                </DropdownWidget>
            </NavbarItem>

            <NavbarItem>
                <BasePrefer/>
            </NavbarItem>

            <NavbarItem class="ms-2">
                <BaseLogout/>
            </NavbarItem>

        </NavbarGroup>
    </NavbarMenu>
</Navbar>

@code {
    /// <summary>
    /// 当前会话状态
    /// </summary>
    [CascadingParameter]
    public SessionState State { get; set; } = new();

    /// <summary>
    /// 检索跳转
    /// </summary>
    /// <param name="item"></param>
    /// <returns></returns>
    public Task OnSelectedItemChanged(MenuItem item)
    {
        if (!string.IsNullOrWhiteSpace(item.Url))
        {
            Navigation.NavigateTo(item.Url);
        }
        return Task.CompletedTask;
    }
}
